﻿/*版权声明
 * 
 * 本 WebName:IMIS_ERP 由
 * 河北大学 信管团队 开发
 * 如有任何疑问请联系开发人员
 * 
 * 项目开发者
 * 负责人：朱胜贤
 * 成员：水亚亚、孙旭峰、张文元、项玥、吕芳、吴凡、谢静、李亚慧
 * 
 * 如有任何疑问请联系：河北大学信管团队
 * QQ：196396337
 * Email:zagelover@163.com
 * HomePage：http://sxgzs.com/
 * 
 * CopyRight (c) 河北大学信管团队 2010~2020
 * 
 * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * 
 * 
 * 同步更新大学生/旗舰店相关操作
 * 
 * 
 * 
 */

using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Text;
using System.Data;
using System.Drawing;
namespace IMIS_ERP.Web.Order_Info
{
    public partial class List : Page
    {

        IMIS_ERP.BLL.Order_Info bll = new IMIS_ERP.BLL.Order_Info();

        /// <summary>页面加载事件
        ///     <remarks>2010-12-08 河北大学信管团队</remarks>
        /// </summary>
        protected void Page_Load(object sender, EventArgs e)
        {
            lblMessage.Text = "";
            if (!IsPostBack)
            {
                ViewState["condition"] = "";
                if (Request.Params["msg"] != null && Request.Params["msg"].Trim() != "")
                {
                    if (Request.Params["msg"].ToString() == "a")
                    {
                        lblMessage.Text = "添加信息成功";
                    }
                    else if (Request.Params["msg"].ToString() == "u")
                    {
                        lblMessage.Text = "修改信息成功";
                    }
                }
                Bind_GV();
            }
        }

        /// <summary>重写OnInit方法
        /// 	<remark>2010-12-08 河北大学信管团队 </remark>
        /// </summary>
        override protected void OnInit(EventArgs e)
        {
            base.OnInit(e);
            Pagination1.NavigationClick += new ImageClickEventHandler(Pager_NavigationClick);
        }

        /// <summary>响应导航控件事件——重新绑定数据
        /// 	<remark>2010-12-08 河北大学信管团队 </remark>
        /// </summary>
        private void Pager_NavigationClick(object sender, ImageClickEventArgs e)
        {
            Bind_GV();
        }

        /// <summary>单击按钮事件：查询
        ///     <remarks>2010-12-08 河北大学信管团队</remarks>
        /// </summary>
        protected void btnSearch_Click(object sender, EventArgs e)
        {
            ViewState["condition"] = " and " + ddlSearch.SelectedValue + " like '%" + txtSearch.Text.Trim() + "%'";
            Bind_GV();
        }

        /// <summary>单击按钮事件：清空
        ///     <remarks>2010-12-08 河北大学信管团队</remarks>
        /// </summary>
        protected void btnCancel_Click(object sender, EventArgs e)
        {
            txtSearch.Text = "";
        }

        /// <summary>绑定数据：GridView
        ///     <remarks>2010-12-08 河北大学信管团队</remarks>
        /// </summary>
        public void Bind_GV()
        {
            IMIS_ERP.BLL.Pub_GetData bsns = new IMIS_ERP.BLL.Pub_GetData();
            Model.Pub_GetData model = new Model.Pub_GetData();
            //需要查询的表
            model.TableName = "Order_Info";
            //作为分页的字段
            model.PrimaryKey = "oiID";
            //查询字段
            model.FieldList = "oiID,oiTime,oiCusName,oIDelivTime,oiMeasure,oiAddvance,oiContractFee,oiSettleFee,oiIsToTask,oiIsCancel,oiIsSendToF,oiIsBackToS,oiStatus";
            //查询条件
            model.Condition = "oiSiID='" + Session["siID"].ToString() + "'" + ViewState["condition"].ToString();
            //当前页
            model.SortType = 3;
            model.Order = "oiTime desc";
            model.PageIndex = Pagination1.PageCurrent;
            lblPageNow.Text = Pagination1.PageCurrent.ToString();
            //获得数据s
            DataSet ds = bsns.GetPage(model);
            //取得总页数
            Pagination1.PageSum = Convert.ToInt32(ds.Tables[1].Rows[0]["pageSum"]);
            lblPageCount.Text = ds.Tables[1].Rows[0]["pageSum"].ToString();
            lblRecordCount.Text = ds.Tables[1].Rows[0]["recordSum"].ToString();
            //为GridView绑定赋予数据源
            GV.DataSource = ds.Tables[0].DefaultView;
            //为GridView绑定数据
            GV.DataBind();
            if (Convert.ToBoolean(Session["siIsFlagship"]))
            {
                GV.Columns[6].Visible = false;
            }
        }

        /// <summary>响应GridView事件：创建数据行时
        /// 	<remark>2010-12-08 BY 河北大学信管团队</remark>
        /// </summary>
        protected void GV_RowCreated(object sender, GridViewRowEventArgs e)
        {
            if (e.Row.RowType == DataControlRowType.DataRow)
            {
                //为数据行增加鼠标移动到行特性
                e.Row.Attributes.Add("onmouseover", "c=style.backgroundColor;this.style.backgroundColor='" + IMIS_ERP.BLL.Assistant.getColor1 + "'");
                //为数据行增加鼠标离开行特性
                e.Row.Attributes.Add("onmouseout", "this.style.backgroundColor=c");
            }
        }

        /// <summary>响应GridView事件：删除记录时
        /// 	<remark>2010-12-03 BY 河北大学信管团队</remark>
        /// </summary>
        protected void GV_RowDeleting(object sender, GridViewDeleteEventArgs e)
        {
            if (((CheckBox)GV.Rows[e.RowIndex].Cells[9].Controls[0]).Checked)
            {
                lblMessage.Text = "已经提交给加工中心的订单不能删除";
                return;
            }
            if (bll.Delete(GV.DataKeys[e.RowIndex][0].ToString()))
            {
                lblMessage.Text = "删除订单成功";
                Bind_GV();
            }
            else
            {
                lblMessage.Text = "删除订单失败";
            }
        }

    }
}
